﻿using System.Threading;
using System.Web.Mvc;
using Peak.Core;
using Peak.Resources;

namespace Peak.Web.Controllers.HtmlExtentions
{
  public static class AssignedToExtension
  {
    public static MvcHtmlString AssignedTo(this HtmlHelper html,User assignedTo)
    {
      if(assignedTo == null)
        return MvcHtmlString.Create(Labels.Unassigned);

      if (assignedTo.UserName == Thread.CurrentPrincipal.Identity.Name)
        return MvcHtmlString.Create(Labels.Me);
      else
        return MvcHtmlString.Create(assignedTo.UserName);
    }
  }
}
